package com.bootdo.acitvity.DDD.domain.entity;

import lombok.Getter;

public class Stock implements Comparable<Stock> {

    public static final Stock ZERO = new Stock();

    @Getter
    private Long stockAmount;

    public Stock() {
        stockAmount = 0L;
    }

    public Stock(Long stockAmount) {
        this.stockAmount = stockAmount;
    }


    @Override
    public int compareTo(Stock stock) {
        return this.stockAmount.compareTo(stock.getStockAmount());
    }

    public boolean isEnough(Stock stock){
        if(compareTo(stock) >= 0){
            return true;
        }else {
            return false;
        }
    }

    public  Stock reduce(Stock stock){
        return new Stock(this.getStockAmount()- stock.getStockAmount());
    }

    public  Stock add(Stock stock){
        return new Stock(this.getStockAmount() + stock.getStockAmount());
    }
}
